#include "base.h"
#include "napi/native_api.h"
#include <exception>

#ifndef HAR_RELEASE_H
#define HAR_RELEASE_H
struct ReleaseCallbackData {
    napi_async_work asyncWork;
    napi_deferred deferred;
    napi_ref callback;
};

static void ReleaseExecute(napi_env env, void *data) {
    try {
        if (document != NULL) {
            ddjvu_job_release(ddjvu_document_job(document));
        }
        ddjvu_context_release(instance);
    } catch (std::exception &e) {
    }
}

static void ReleaseComplete(napi_env env, napi_status status, void *data) {
    ReleaseCallbackData *callbackData = reinterpret_cast<ReleaseCallbackData *>(data);
    napi_resolve_deferred(env, callbackData->deferred, nullptr);
    napi_delete_async_work(env, callbackData->asyncWork);
    delete callbackData;
}
#endif
